#include <head.h>
int main(int argc, char const *argv[])
{
  int fd = open("共同.txt", O_RDWR | O_CREAT, 0666);

  int fd_T = open("T.txt", O_RDWR | O_CREAT, 0666);

  int i = 10;
  int T_num;
  char buff[32] = "B";

  flock(fd, LOCK_EX);

  read(fd_T, &T_num, sizeof(int)); // 从文件中读取偏移量
  lseek(fd, T_num, SEEK_SET);      // 从SEEK_SET位置偏移T_num个字节,继续向文件中写数据
  while (i--)
  {
    write(fd, buff, 1);
    sleep(1);
  }
  flock(fd, LOCK_UN);

  close(fd);
  close(fd_T);
  return 0;
}